package com.LatitudeYao;

/**
 * Created by GTS on 2017/8/21.
 */
public class MyPower {
    public double Power(double base ,int exp){
        if(exp == 0){
            return 1;
        }
        else if(exp == 1){
            return base;
        }
        double result  = Power(base, exp >> 1);
        result = result * result;
        if((exp & 0x1) == 1){
            result *= base;
        }
        return result;
    }

    public static void main(String[] args) {
        MyPower myPower = new MyPower();
        System.out.println(myPower.Power(1.5,2));
        System.out.println(myPower.Power(2,3));

    }

}
